<template>
  <div class="divs">
    <img :src="indurl" alt="" />
    <p @click="btn" :style="{ background: color }">{{ indname }}</p>
  </div>
</template>

<script>
export default {
  props: ["indurl", "indname"],
  data() {
    return {
      color: "",
    };
  },
  methods: {
    btn() {
      this.color = `rgb(${Math.floor(Math.random() * 256)}, ${Math.floor(
        Math.random() * 256
      )}, ${Math.floor(Math.random() * 256)})`;
      this.$emit("xihuan", this.indname);
    },
  },
};
</script>

<style>
.divs {
  width: 400px;

  border: 1px solid #000;
  text-align: center;
  float: left;
}
img {
  width: 100%;
}
</style>